package yawning.mew.cat;

import yawning.mew.sim.SimulationAction;
import yawning.mew.sim.SimulationEventAction;

public class EventSavageRoar extends SimulationEventAction {
	private CatModelSimState mState;
	
	EventSavageRoar(CatModelSimState state) {
		super(state.mSimUtil);
		mState = state;
	}

	@Override
	public double perform() {
		if (mState.energyTickEv.mEnergy < mState.mModel.srCost || mState.mComboPoints == 0) return SimulationAction.ACTION_FAIL; // SR is affected by neither Berserk nor OoC.

		// The game will happily let us clip SR with a weaker buff, unlike S&D.
		schedule(mState.mModel.roarInitialDuration + mState.mModel.roarCpBonus * mState.mComboPoints);

		if (mState.mDebug) mState.DBGF("Savage Roar (%d)", mState.mComboPoints);

		mState.nrSR++;
		mState.nrSrCPs += mState.mComboPoints;
		mState.mComboPoints = 0;
		mState.energyTickEv.mEnergy -= mState.mModel.srCost;
		return 1.0;
	}

	@Override
	public void onExpire() {
		if (mState.mDebug) mState.DBGF("Savage Roar Expiration");
	}
}